package sys.cloud.demo.datastructure;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by shiyusen on 2017/3/22.
 */
public class FailFastExample {
    public static void main(String[] args)
    {
        Map<String,String> premiumPhone = new HashMap<String,String>();
        premiumPhone.put("Apple", "iPhone");
        premiumPhone.put("HTC", "HTC one");
        premiumPhone.put("Samsung","S5");

        Iterator<String> iterator = premiumPhone.keySet().iterator();

        while (iterator.hasNext())
        {
            String key = iterator.next();
//            iterator.remove();//不会fastfail
//            premiumPhone.put("Sony", "Xperia Z");//会
            premiumPhone.remove(key);//会
        }

    }
}
